<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>双向绑定</title>
</head>
<body>
    <div id="app">
        {{info.code}}
        {{info.result}}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <script>
        
        var vue =new Vue({
            el:"#app",
            data(){//data()函数,去扥data属性
                return {
                    info:{//vue自定义的变量
                        code:null,
                        result:{
                            name:null,
                            age:null
                        }
                    }
                }
            },
            mounted(){//钩子函数，VUE生命周期，钩子函数一般用来初始化
                axios.get("./data.json").then((result) => {
                    this.info=result.data
                }).catch((err) => {
                    
                });
            },    
        })  
    </script>
</body>
</html>